<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<title>商品列表</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="css/bootstrap.css" />
<link rel="stylesheet" href="css/amazeui.min.css" />
</head>
<body>
	<div class="container">

		<%@include file="header.jsp"%>

		<div class="text-right">
			<a class="btn btn-warning" href="findType.do">添加商品</a>
		</div>

		<br>

		<ul role="tablist" class="nav nav-tabs">
			<li <c:if test='${type==0}'>class="active"</c:if> role="presentation"><a
				href="goodList">全部商品</a></li>
			<li <c:if test='${type==1}'>class="active"</c:if> role="presentation"><a
				href="goodList?type=1">今日推荐</a></li>
		</ul>



		<br>

		<table class="table table-bordered table-hover">

			<tr>
				<th width="3%">ID</th>
				<th width="5%">图片</th>
				<th width="10%">名称</th>
				<th width="10%">介绍</th>
				<th width="5%">规格</th>
				<th width="3%">价格</th>
				<th width="5%">类目</th>
				<th width="3%">库存</th>
				<th width="3%">销量</th>
				<th width="5%">操作</th>
			</tr>

			<c:forEach var="good" items="${list}">
				<tr>
					<td><p>${good.id}</p></td>
					<td><p>
							<a href="../index/detail?id=${good.id}" target="_blank"><img
								src="${good.cover}" width="100px"></a>
						</p></td>
					<td><p>
							<a href="../index/detail?id=${good.id}" target="_blank">${good.name}</a>
						</p></td>
					<td><p>${good.intro}</p></td>
					<td><p>${good.spec}</p></td>
					<td><p>${good.price}</p></td>
					<td><p>${good.type.name}</p></td>
					<td><p>${good.stock}</p></td>
					<td><p>${good.sales}</p></td>
					<td>
						<p>
							<a class="btn btn-success topDelete" href="topDelete.do?goodId=${good.id}" type="1"
								 text="加入今日推荐">移出今日推荐</a>
				            <a class="btn btn-primary topSave" href="topSave.do?goodId=${good.id}&type=1" 
								 text="移出今日推荐">加入今日推荐</a>
						</p> <a class="btn btn-info" href="findGoodById.do?id=${good.id}">修改</a> 
						<a class="btn btn-danger" href="goodDelete.do?id=${good.id}">删除</a>
					</td>
				</tr>
			</c:forEach>

		</table>
		<br>${pageTool}<br>

	</div>
	<div class="am-cf" style="margin-right: 30px;">
		共${page.pageSize }条记录
		<div class="am-fr" style="float: none">
			<ul class="am-pagination">
				<li <c:if test="${page.curPage==1}"> class="am-disabled"</c:if>>
					<a href="goodList.do?curPage=${page.curPage-1}">«</a>
				</li>

				<c:forEach begin="1" end="${page.pages}" step="1" var="p">
					<li <c:if test="${p==page.curPage}"> class="am-active"</c:if>>
						<a href="goodList.do?curPage=${p}">${p}</a>
					</li>
				</c:forEach>
				<li <c:if test="${page.curPage==page.pages}"> class="am-disabled"</c:if>>
					<a href="goodList.do?curPage=${page.curPage+1}">>></a>
				</li>
			</ul>
		</div>
		
	</div>
	
	<c:if test='${type==1}'><div class="am-cf" style="margin-right: 30px;">
		共${page.pageSize }条记录
		<div class="am-fr" style="float: none">
			<ul class="am-pagination">
				<li <c:if test="${page.curPage==1}"> class="am-disabled"</c:if>>
					<a href="goodList?type=1&curPage=${page.curPage-1}">«</a>
				</li>

				<c:forEach begin="1" end="${page.pages}" step="1" var="p">
					<li <c:if test="${p==page.curPage}"> class="am-active"</c:if>>
						<a href="goodList?type=1&curPage=${p}">${p}</a>
					</li>
				</c:forEach>
				<li <c:if test="${page.curPage==page.pages}"> class="am-disabled"</c:if>>
					<a href="goodList?type=1&curPage=${page.curPage+1}">>></a>
				</li>
			</ul>
		</div>
	</div></c:if>

	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript">
	

</script>
</body>
</html>